<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<style type="text/css">
	body{
		/*width: 2.3rem;*/
	}
	#diao{
		border: 2px solid red;
		margin: 200px auto 10px;
		width: 2.3rem;
		height: 200px;
	}
	#diao img{
		max-width: 200px;
	}
	.box{
		width: 100px;
		height: 100px;
		border: 1px solid red;
	}
	.box img{
		max-width: 100px;
	}
</style>
<body>
	<div id="diao">111</div>
	<div class="box">
		
	</div>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
	<input type="checkbox" id="test" checked="true" abc="111" onclick="attrp()" /> 
</body>
<script type="text/javascript">
	// const ary = arr => Math.max(...arr);
	// [a,b,c] = [12,34,545,65,76]
	// console.log(a);
	// console.log(b);
	// console.log(c);
	// console.log(ary([2,45,6,7,4]))
	// console.log(Math.max(23,435,654,6,7,78))
	

	// function pageAdap(width,min,max) {
	// 	if(typeof width!=="number"||typeof min!=="number"||typeof max!=="number"){
	// 		// console.log("页面自适应的参数未传或部位数字");
	// 	};
	//     var w = document.body.clientWidth;
	//     var max = parseInt(max)||960;
	//     var min = parseInt(min)||320;
	//     var width = parseInt(width)/100||6.4;
	// 	w=w>max?max:w;
	// 	w=w<min?min:w;
	// 	// console.log(width+"="+min+"="+max+"="+w)
	// 	document.querySelector("html").style.fontSize = w/width+'px';
	// }
	// window.onresize=function(){
	// 	pageAdap(232,'235ter','ret636rtre');
		
	// }

	// pageAdap(232,'235ter','ret636rtre');

	function Haha(str){
		this.str = str;
		console.log(this.str);
	}

	// Haha.prototype.after = function(afterfn){
	// 	var __self = this;
	// 	return function(){
	// 		// clog();
	// 		afterfn.apply(this, arguments);
	// 	};
	// };
	var clog = function(){
		console.log("Old coding ……");
	}

	// clog1 = clog.after(function(){
	// 	console.log("im new coding……111111111");
	// });

	// clog1();
	
	Function.prototype.after = function(afterfn){
		var __self = this;
		return function(){
			var ret = __self.apply(this,arguments);
			//7/ var ret = __self;
			afterfn.apply(this, arguments);
			return ret;
		};
	};



	// clog = (clog||function(){}).after(function(){
	// 	console.log("im new coding……");
	// });
	clog();

	// dlog = dlog.after(function(){
	// 	console.log( "添加的新功能……" )
	// })






	function attrp(){
		setTimeout(function(){
			console.log(document.getElementById('test').checked);
			console.log(document.getElementById('test').abc);
			console.log(document.getElementById('test').getAttribute('checked'));
			console.log(document.getElementById('test').getAttribute('abc'));
			
		}, 100)
	}
	var myImage = (function(){
		var imgNode = document.createElement('img');
		
		return{
			setSrc: function(src,dom){
				if(!isDom){
					alert("请传入dom");
				}
				if(dom){
					dom.appendChild(imgNode);
				}else{
					document.body.appendChild(imgNode);
				}
				imgNode.src = src;
			}
		}
	})();

	var proxyImage = (function(){
		var img = new Image;
		img.onload = function(){
			myImage.setSrc(this.src,this.dom);
		};
		return{
			setSrc: function( src ,dom,oimg){
				myImage.setSrc(oimg,dom);
				img.dom = dom;
				img.src = src;
			}
		}
	})();

	function isDom(obj){
		var isdom = (typeof HTMLElement ==='object')?function(){
			return (obj instanceof HTMLElement);
		}:function(){
			return obj && (typeof obj ==='object') && (obj.nodeType===1) && (typeof obj.nodeName==='string');
		}
		return !!isdom();
	}
	// var haha = isDom('eret');
	var haha = isDom(document.getElementById("diao"));
	// var haha = isDom(document.getElementById("diao"));
	console.log(haha);

	proxyImage.setSrc('https://cdn.dribbble.com/users/1992697/screenshots/4025385/hello_dribbble.png',document.getElementById("diao"),'imgs/timg.jpg');

	window.addEventListener('click',function(){
		if(event.target.className=='box'){
			proxyImage.setSrc('https://cdn.dribbble.com/users/1992697/screenshots/4025385/hello_dribbble.png',event.target,'imgs/timg.jpg');
		}
	},0)

	function guige(){
		//选择规则
		// 切换规格
	}
</script>
</html>